package org.zjt.book

import scala.collection.mutable.ArrayBuffer

/**
  * DESC    
  *
  * @author
  * @create 2017-04-25 下午5:52
  **/
object ArrayBufferTest {

  def main(args: Array[String]): Unit = {
    var arrayBuffer = ArrayBuffer[Int]()

    for(i <- 0 until 100 if(arrayBuffer.size <= 10))
      if(i % 2 == 0) arrayBuffer += i


    var arrayBuffer1 = ArrayBuffer[Int]()

    for(i <- 0 until 100 if(arrayBuffer1.size <= 10))
      if(i % 2 == 0) arrayBuffer1 += i

    println(arrayBuffer.mkString(","))

    arrayBuffer ++= arrayBuffer1
    //追加数组到另一个数组
    println("ssss"+ arrayBuffer.mkString(","))



    println(arrayBuffer ++ arrayBuffer1)


    println( arrayBuffer.toString())

    // copyToArray( Array[超类]() ) 将this拷贝到超类数组中
    var a =Array[Any](10,23,43,43,34)
    arrayBuffer.copyToArray(a)
    println(a.mkString(",")+"\n" + arrayBuffer.mkString(",") )


    // padTo(length,element) 如果长度不足length，用element补齐
    println("padTo:"+arrayBuffer.padTo(25,6).mkString(","))

    println("total:"+arrayBuffer.padTo(25,6).count(a => true)+  "   count:"+arrayBuffer.padTo(25,6).count( _ > 5 ))
  }

}
